﻿using Microsoft.Extensions.DependencyInjection;
using Spark.AspNetCore;
using Spark.Core.ServiceDiscovery;

namespace Spark.ServiceDiscovery.Remote.Extensions
{
    public class ServiceDiscoveryRemoteOptionsExtension : IOptionsExtension
    {
        private readonly RemoteServiceDiscoveryConfiguration _options;

        public ServiceDiscoveryRemoteOptionsExtension(RemoteServiceDiscoveryConfiguration options)
        {
            _options = options;
        }

        public void AddServices(IServiceCollection services)
        {
            services.AddSingleton(_options);
            services.AddSingleton<IRemoteClient, RemoteClient>();
            services.AddSingleton<IServiceDiscovery, RemoteServiceDiscovery>();
        }
    }
}